package com.xiaoyu.client.adapter.discovery;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xiaoyu.client.R;
import com.xiaoyu.client.model.discovery.NoticeThankBean.DataBean.NoticeBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 公告item适配器
 * Created by jk on 2018/10/17.
 */
public class NoticeAdapter extends BaseAdapter {
    private Context mContext;
    private List<NoticeBean> mList = new ArrayList<>();

    public NoticeAdapter(Context mContext, List<NoticeBean> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public NoticeBean getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    class ViewHolder{
        TextView titleTxt;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null){
            convertView = View.inflate(mContext, R.layout.item_notice,null);
            holder = new ViewHolder();
            holder.titleTxt = convertView.findViewById(R.id.item_notice_content);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.titleTxt.setText(getItem(position).getFourmtitle());

        return convertView;
    }

    public void updateList(List<NoticeBean> list){
        this.mList = list;
        this.notifyDataSetChanged();
    }
}
